package com.gem.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gem.entity.User;
import com.gem.mapper.UserMapper;
import com.gem.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import static com.gem.util.PageUtil.PAGESIZE;

/**
 * @author 刘聪
 * Created  on 2021/3/2
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Autowired
    private UserMapper userMapper;
    @Override
    public Page selectAll(Integer pageNum) {
        Page<User> page = new Page<>(pageNum, PAGESIZE);
        QueryWrapper wrapper = new QueryWrapper();

        Page userPage = userMapper.selectPage(page, wrapper);
        return userPage;
    }

    @Override
    public User selectById(Integer id) {
        return userMapper.selectById(id);
    }

    @Override
    public User selectByName(String name) {
        return userMapper.selectByName(name);
    }
}
